package com.amit.struts;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class AddContactAction  extends Action{
	
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		System.out.println("execute()-AddContactAction");
		
		String result="AddContactSuccess";
		
		//1.collect the data
		
		ContactForm acf=(ContactForm) form;
		
		String fn=acf.getFname();
		String ln=acf.getLname();
		String em=acf.getEmail();
		String ph=acf.getPhone();
		
		
		System.out.println(fn);
		System.out.println(ln);
		System.out.println(em);
		System.out.println(ph);
		
		
		
		ContactTO cto=new  ContactTO();
		
		cto.setFname(fn);
		cto.setLname(ln);
		cto.setEmail(em);
		cto.setPhone(ph);
		
		
		request.setAttribute("CTO", cto);
		
		return mapping.findForward(result);
		
	
	}

}
